import request from '@/utils/request'
import Qs from 'qs'

export function listSupplier(query) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.supplier',
      _mt: 'list',
      ...query
    }
  })
}

export function auditSupplier(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.supplier',
      _mt: 'auditSupplier',
      id: data.id,
      status: data.status
    })
  })
}

export function createSupplier(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.supplier',
      _mt: 'create',
      supplierDTO: JSON.stringify(data)
    })
  })
}

export function updateSupplier(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.supplier',
      _mt: 'edit',
      supplierDTO: JSON.stringify(data)
    })
  })
}

export function deleteSupplier(id, nickname) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.supplier',
      _mt: 'delete',
      id: id
    })
  })
}
